﻿<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
	<meta charset="utf-8" />
    <script src="js/jquery-2.1.1.min.js"></script>
    <!--<script src="js/表格.js" defer></script>-->
    <style type="text/css">
        *{
            margin:0;
            padding:0;
        }
        .tab{
            width:80vw;
            margin:0 auto;
            border-color:blue;
        }
        
    </style>
   </head>
<body>
    <!--<input type="hidden" value="刷新" onclick="sx()" />
    <input type="hidden" value="取消" onclick="quxiao()" />-->
    <table id="show_tab" class="tab" border="1">
        <thead>
            <tr>
                <th>姓名</th>
                <th>测试结果</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
     <input id="lastpage" type="hidden" value="上一页" >
    <input id="curPage" type="hidden" size="5">
    <input id="npage" type="hidden" value="确定">
    <input id="nextpage" type="hidden" value="下一页">
    <input id="page" type="hidden" size="1" readonly="readonly">
    <!--每页显示<input id="pageSize" type="text" value="2" size="5">行<input type="button" value="确定" onclick="pageSize2()">-->
</body>
</html>
<script type="text/javascript">
    var qwe = "";
    var q = 1;
    var curPage = 0;
    var pageSize =0;
    var len;         //总行数
    var page;        //总页数
  function sx(){
        $.get("显示.ashx", {},
            function (date) {          
            $("table tbody").html("");
            $("#show_tab tbody").append(date);
            pageSize = 3;//显示的行数
            len = $("#show_tab tr").length - 1;   //去掉表头     
            page = len % pageSize == 0 ? len / pageSize : Math.floor(len / pageSize) + 1;//根据记录条数，计算页数
            
            if (qwe == date) {
                if (curPage == page) {
                    curPage = 0;
                }
                curPage += 1;
            }
            else {
                curPage = 1;
            }
            console.log("len:" + len + "   page:" + page);
            document.getElementById("page").value = page;
            var begin = (curPage - 1) * pageSize;//起始记录号
            var end = begin + pageSize;
            console.log("  begin:" + len + "   end:" + end);
            if (end > len) end = len;
            $("#show_tab tr").hide();
            $("#show_tab tr").each(function (i) {
                if (i - 1 >= begin && i - 1 < end)//显示第page页的记录
                {
                    $("#show_tab_one").show();
                    $(this).show();
                }
            });
            qwe = date;
            });
       
  }
  window.onload = sx();
    setInterval("sx()", 5000);
    $(function () {
        len = $("#show_tab tr").length - 1;   //去掉表头     
        page = len % pageSize == 0 ? len / pageSize : Math.floor(len / pageSize) + 1;//根据记录条数，计算页数
        console.log("len:" + len + "page:" + page);
        document.getElementById("page").value = page;
        curPage = 1;
        displayPage();//显示第一页
    });
</script>
